<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="applicable-device" content="pc">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="icon" href="/icon.png" />
    <link rel="stylesheet" href="/static/index/css/reset.css">
    <link rel="stylesheet" href="/static/index/lib/bootstrap.css">
    <link rel="stylesheet" href="/static/index/css/common.css">
    <link rel="stylesheet" href="/static/index/css/home.css">
    <link rel="stylesheet" href="/static/index/css/users.css">
    <script src="/static/index/lib/jquery-2.1.4.js"></script>
    <script>
            var _hmt = _hmt || [];
            (function() {
              var hm = document.createElement("script");
              hm.src = "https://hm.baidu.com/hm.js?8b340ebdd740974de9d621b14ab09b43";
              var s = document.getElementsByTagName("script")[0]; 
              s.parentNode.insertBefore(hm, s);
            })();
        </script>
    <script type="text/javascript" src="/static/index/lib/template.js"></script>
</head>

<body>
    {include file="public/push"}
    {include file="public/usersHeader"}
    <div class="widthFullScreen">
        <div class="wdSafe user_body clearfix">
            {include file="public/usersLeftNav"}
            <!-- left over -->
            <div class="pull-right right_wrap">
                <div class="nav_common border-top">
                    <ol class="breadcrumb pull-left">
                        <li><a href="/users/index">用户中心</a></li>
                        <li><a href="/users/index">我的资料</a></li>
                        <li class="active">资质案例</li>
                    </ol>
                    <a href="/users/companyAddCase" class="pull-right colorRed" style="line-height: 50px;">+添加案例</a>
                </div>
                <div class="comUser_wrap">
                    <div id="inforHtml"></div>
                    <script id="inforScript" type="text/html">
                        <div class="row" style="margin: 0;">
                            {{each data item i}} 
                                <div class="col-md-3 anli_wrap">
                                    <img class="anliPic" src="{{item.poster}}" alt="" />
                                    <ul class="anli_list_audit">
                                        <li>
                                            <a href="/users/companyEditCase/{{item.id}}">编辑</a>
                                        </li>
                                        <li>
                                            <a href="javascript:;" onclick="deletTeam(this)">删除</a>
                                        </li>
                                        <li>
                                            <a href="javascript:;">{{item.isHid}}</a>
                                        </li>
                                    </ul>
                                </div>
                            {{/each}}  
                        </div>
                    </script>
                </div>
            </div>
            <!-- right over -->
        </div>
    </div>
    <div class="widthFullScreen heightGray"></div>
    {include file="public/footer"}

    <script type="text/javascript" src="/static/index/layer/layer.js"></script>
    <script type="text/javascript">
        var baseUrl = 'https://api.qikuai100.com/',
            uid = localStorage.getItem("uid");
        $(function() {
            initDate();
        });
        /**
         * 初始化数据
         */
        function initDate() {
            $.ajax({
                type: "POST",
                url: baseUrl + "api/case/list",
                data: {
                    uid: uid
                },
                success: function(result) {
                    if (result.ret == 0) {
                        if(result.data.length == 0 || !result.data.length){
                            layer.msg("您还没有案例，快去添加吧！");
                        }else{
                            for(var i =0;i <result.data.length; i++){
                                if(result.data[i].is_hidden == 1){
                                    result.data[i].isHid = "显示";
                                }else{
                                    result.data[i].isHid = "隐藏";
                                }
                            }
                        }
                        var inforHtml = template('inforScript', result);
                        document.getElementById('inforHtml').innerHTML = inforHtml;

                    } else {
                        layer.msg(result.res_info);
                    }
                }
            });
        };

        /**
         * 删除团队
         */
        function deletTeam(obj){
            var id = $(obj).parents("ul").attr("dId");
            layer.open({
                title: '删除'
                ,content: '您确定要删除此案例信息吗?删除后不可恢复。',
                yes: function(index, layero){
                    $.ajax({
                        type: "POST",
                        url: baseUrl + "api/case/del",
                        data: {
                            id: id
                        },
                        success: function(result) {
                            if (result.ret == 0) {
                                layer.msg("删除成功！");
                                initDate();
                            } else {
                                layer.msg(result.res_info);
                            }
                        }
                    });
                    layer.close(index);
                }
            }); 
            
        }

        
    </script>
</body>

</html>